# -*- encoding: utf-8 -*-
from collections import defaultdict


class AdjacencyList(object):
    def __init__(self):
        self.graph = defaultdict(list)

    def add_edge(self, x, y):
        self.graph[x].append(y)

    def print_graph(self):
        for x, y in self.graph.items():
            print(x, '->', ' -> '.join([str(i) for i in y]))


if __name__ == '__main__':
    al = AdjacencyList()
    al.add_edge(0, 1)
    al.add_edge(0, 4)
    al.add_edge(4, 1)
    al.add_edge(4, 3)
    al.add_edge(1, 0)
    al.add_edge(1, 4)
    al.add_edge(1, 3)
    al.add_edge(1, 2)
    al.add_edge(2, 3)
    al.add_edge(3, 4)

    al.print_graph()
